ruby: wrap script to disable gems if not installed
authorLuiz Angelo Daros de Luca <[email protected]>
Sat, 4 Oct 2014 19:54:24 +0000 (16:54 -0300)
committerLuiz Angelo Daros de Luca <[email protected]>
Tue, 7 Oct 2014 17:14:52 +0000 (14:14 -0300)
ruby, by default, try to load gems on start. If not
present, it fails. As gems brings many deps, this make ruby
unsuitable for routers limited resources.

ruby can avoid to load gems with the option "--disable-gems".
So, a wrap script in the place of /usr/bin/ruby adds this option
if gems are not found.

Also add vendor/site directories

Signed-off-by: Luiz Angelo Daros de Luca <[email protected]>
lang/ruby/Makefile
lang/ruby/files/ruby [new file with mode: 0644]

index c540e779221028d2b351f782136920ccf90d7b0b..66d58e33a28741bce67e2b1f48fe1dd2ae985234 100644 (file)
@@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ruby
 PKG_VERSION:=2.1.2
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_LIBVER:=2.1
 
@@ -223,7 +223,13 @@ MAKE_FLAGS += \
 
 define Package/ruby/install
        $(INSTALL_DIR) $(1)/usr/bin
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ruby $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/usr/lib/ruby/$(PKG_LIBVER)
+       $(INSTALL_DIR) $(1)/usr/lib/ruby/vendor_ruby/$(PKG_LIBVER)
+       $(INSTALL_DIR) $(1)/usr/lib/ruby/site_ruby/$(PKG_LIBVER)
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ruby $(1)/usr/lib/ruby/ruby$(PKG_LIBVER)-bin
+       $(INSTALL_BIN) ./files/ruby $(1)/usr/bin/ruby
+       sed -i -e "s%@RUBY_LIBPATH@%/usr/lib/ruby/$(PKG_LIBVER)%" $(1)/usr/bin/ruby
+       sed -i -e "s%@RUBY_BINPATH@%/usr/lib/ruby/ruby$(PKG_LIBVER)-bin%" $(1)/usr/bin/ruby
 endef
 
 define Package/libruby/install
diff --git a/lang/ruby/files/ruby b/lang/ruby/files/ruby
new file mode 100644 (file)
index 0000000..e4904fc
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+if ! [ -r "@RUBY_LIBPATH@/rubygems.rb" ]; then
+       exec @RUBY_BINPATH@ --disable-gems "$@"
+fi
+exec @RUBY_BINPATH@ "$@"